<?php
/*
 * list File
 *
 * @link http://riedel-st.de
 * @author Stefan Riedel <sr@riedel-st.de>
 */
?>
<?php $this->pageTitle=Yii::app()->name . ' :: ' . Yii::t('crm', 'Kontakte Übersicht'); ?>
<h3><?=Yii::t('crm', 'Kontakte Übersicht')?></h3>
<?php if($customer): ?>
<div id="showTable">
	<table border="0" cellspacing="2" cellpadding="0" class="ui-widget-content ui-corner-all">
	    <thead class="ui-widget-header">
	        <tr>
	            <th><?=Yii::t('crm', 'Firmenname')?></th>
	            <th><?=Yii::t('crm', 'Name Ansprechhpartner')?></th>
	            <th><?=Yii::t('crm', 'PLZ/Ort')?></th>
	            <th><?=Yii::t('crm', 'Telefon')?></th>
	            <th><?=Yii::t('crm', 'E-Mail-Adresse')?></th>
	            <th> </th>
	        </tr>
	    </thead>
	<?php foreach($customer as $n => $cust):
			/**
			 * @todo refaktorieren auslagern
			 * @var unknown_type
			 */
			$numberText = (!empty($cust->customers_area_code)) ? CHtml::encode($cust->customers_area_code) . '-' : ''; 
			$numberText .= CHtml::encode($cust->customers_telephone);
	?>
		<tr id="tr-<?=CHtml::encode($cust->customers_id)?>" class="state-default<?=$n%2?> js-changer" rel="<?= CRMHtml::normalizeUrlWithCheckAccess(array('show', 'id' => $cust->customers_id), 'CustomerAdressShow', array('id' => $cust->customers_id))?>">
			<td id="td-companyName-<?=CHtml::encode($cust->customers_id)?>"><?=CHtml::encode($cust->customers_company_name)?></td>
			<td id="td-contactName-<?=CHtml::encode($cust->customers_id)?>"><?=CHtml::encode($cust->customers_firstname)?> <?=CHtml::encode($cust->customers_lastname)?></td>
			<td id="td-zipCity-<?=CHtml::encode($cust->customers_id)?>"><?=CHtml::encode($cust->customers_zip)?>/<?=CHtml::encode($cust->customers_city)?></td>
			<td id="td-telephone-<?=CHtml::encode($cust->customers_id)?>"><?=CRMHtml::numberedLinkToCall(CHtml::encode($cust->customers_telephone), Yii::app()->dbConfig->asteriskAmt, CHtml::encode($cust->customers_area_code))?></td>
			<td id="td-email-<?=CHtml::encode($cust->customers_id)?>"><?=CHtml::encode($cust->customers_email)?></td>
			<td id="td-actions-<?=CHtml::encode($cust->customers_id)?>"><?=CRMHtml::linkWithCheckAccess('CustomerAdressShow', CRMHtml::image(CRMHtml::imageUrl('search.png'), Yii::t('crm', 'Komplett Ansicht'), array('title' => Yii::t('crm', 'Komplett Ansicht'))), array('id' => $cust->customers_id), array('show', 'id' => $cust->customers_id))?> <?=CRMHtml::image(CRMHtml::imageUrl('edit.png'), Yii::t('crm', 'Kunden bearbeiten'), array('title' => Yii::t('crm', 'Kunden bearbeiten')))?> <?=CRMHtml::image(CRMHtml::imageUrl('delete.png'), Yii::t('crm', 'Kunden löschen'), array('title' => Yii::t('crm', 'Kunden löschen')))?></td>
		</tr>
	<?php endforeach;?>
	</table>
</div>
<?php $this->widget('CLinkPager',array('pages'=>$pages)); ?>
<?php else: ?>
<p><?=Yii::t('crm', 'Leider sind keine Adressen verfügbar.')?></p>
<?php endif; ?>